package com.cloudkinto.dto.stock.query;

import com.cloudkinto.common.utils.MathUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.RoundingMode;

import cn.afterturn.easypoi.excel.annotation.Excel;


@Data
public class SkuStockDto {

    @Excel(name = "商品ID")
    @ApiModelProperty("商品ID")
    private Long productId;

    @Excel(name = "SKU")
    @ApiModelProperty("SKU")
    private String sku;

    @Excel(name = "SPU")
    @ApiModelProperty("SPU")
    private String spu;

    @Excel(name = "产品名称")
    @ApiModelProperty("产品名称")
    private String productName;

    @Excel(name = "产品分类")
    @ApiModelProperty("产品分类")
    private String fullPathName;

    @Excel(name = "总库存")
    @ApiModelProperty("总库存数")
    private int totalAmount;

    @Excel(name = "在库库存")
    @ApiModelProperty("在库库存 不喊锁定")
    private int availableAmount;

    @Excel(name = "锁定库存")
    @ApiModelProperty("在库锁定库存")
    private int lockAmount;

    @Excel(name = "在途")
    @ApiModelProperty("在途")
    private int transportAmount;

    @Excel(name = "预售在途")
    @ApiModelProperty("预售在途")
    private int inTransitQty;

    @Excel(name = "待处理数量")
    @ApiModelProperty("待处理数量")
    private int toDealQty;

    @Excel(name = "可用库存")
    @ApiModelProperty("可用数(在库库存(不含锁定) + 预售在途 - 待处理数量)")
    private int canUseAmount;

    @Excel(name="近7/14/30天销量")
    private  String sales;


   @Excel(name = "日销量")
   private String dailySalesForExport;

    @ApiModelProperty("日销量")
    private Double dailySales;

    @Excel(name = "可售天数")
    private String canSellDayForExport;

    @ApiModelProperty("可售天数")
    private Double canSellDay;

    @Excel(name = "建议补货数量")
    @ApiModelProperty("建议补货数量")
    private int recommendAmount;

    @Excel(name = "库存状态")
    private String stockStatusName;

    @ApiModelProperty("库存状态 10 尽快补货 20 需要关注 30 滞销 40 库存充足 50 不在售卖")
    private Integer stockStatus;

    @ApiModelProperty("主条码")
    private String mainBarcode;

    @ApiModelProperty("分类id")
    private Long categoryId;

    @ApiModelProperty("库存属性 0正品 1次品")
    private Integer stockAttribute;

    @ApiModelProperty("三日销量")
    private double threeDaysSales;

    @ApiModelProperty("七日销量")
    private double sevenDaysSales;

    @ApiModelProperty("三十日销量")
    private double thirtyDaysSales;

    @ApiModelProperty("近三日权重")
    private double threeDaysWeight;

    @ApiModelProperty("近七日权重")
    private double sevenDaysWeight;

    @ApiModelProperty("近三日权重")
    private double thirtyDaysWeight;


    public Double getDailySales() {
        return MathUtils.numberFormat(dailySales, 2, RoundingMode.UP);
    }

    public void setDailySales(double dailySales) {
        this.dailySales = dailySales;
        // 保留两位小数，但如果是 0.0 就显示为 "0"
        if (dailySales == 0.0) {
            this.dailySalesForExport = "0";
        } else {
            this.dailySalesForExport = String.valueOf(dailySales);
        }
    }

//    public int getCanUseAmount() {
//        return availableAmount + inTransitQty - toDealQty;
//    }
}
